layui.use(['form', 'button', 'popup'], function () {
	var form = layui.form;
	var button = layui.button;
	var popup = layui.popup;
    
	// 登 录 提 交
	form.on('submit(login)', function (data) {
        var ii = layer.load(2, {shade:[0.1,'#fff']});
        $.ajax({
            type : "POST",
            url : "./ajax/login",
            data: JSON.stringify(data.field),
            contentType: 'application/json',
            dataType : 'json',
            success : function(data){
                layer.close(ii);
                if(data.code == 200){
                    truemsg(layer , data.msg,function(){
                        location.href="./";
                    });
                }else{
                    falsemsg(layer , data.msg);
                    refreshCaptcha();
                }
            },
            error: function(data){
                layer.close(ii);
                falsemsg(layer , "服务器错误！");
                refreshCaptcha();
            }
        });

		return false;
	});
})